/*
 * TCSS 422 Web Spider Project
 * Group Money: Al McKenzie, Michael Pitts, Taylor Zielske
 */
package model.domain;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

import model.URLInputCooker;

/**
 * This domain does not block any urls from being searched.
 * 
 * @author Michael Pitts
 * @version Oct 19, 2011
 */
public class OpenDomain extends AbstractDomain {
	
	/**
	 * Stores all the visited urls.
	 */
	private final Set<String> my_visited;

	/**
	 * Creates a new Open Domain, which has no restrictions on searching.
	 * @param the_domain is the string representation of the domain.
	 * @param the_cooker is the cooker that will accept new urls.
	 */
	public OpenDomain(final String the_domain, final URLInputCooker the_cooker) {
		super(the_domain, the_cooker);
		my_visited = Collections.synchronizedSet(new HashSet<String>());
	}

	/**
	 * {@inheritDoc}
	 */
	@Override public void addURL(final String the_url) {
		if (!my_visited.contains(the_url)) {
			my_visited.add(the_url);
			addURLToCooker(the_url);
		}
	}
}
